package cn.itcast.order.mapper;

import cn.itcast.order.pojo.Order;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface OrderMapper {

    @Select("select * from tb_order where id = #{id}")
    Order findById(int id);

    //扣减库存
    @Update("UPDATE tb_order SET num = num - #{num} WHERE id = #{orderId}")
    int updateNumById(int orderId, int num);

    //恢复库存
    @Update("UPDATE tb_order SET num = num + #{freezeNum} WHERE id = #{orderId}")
    void refund(int orderId, int freezeNum);
}
